<script setup>
import { ref } from 'vue'
import { getOrderDetailAPI } from '@/api'
import { useRoute } from 'vue-router'
// 获取订单详情
const orderDetail = ref({})
const route = useRoute()
async function getOrderDetail() {
  const { result } = await getOrderDetailAPI(route.query.orderId)
  orderDetail.value = result
}
getOrderDetail()
// 支付枚举
const PAYTYPE = {
  1: '支付宝',
  2: '微信',
  3: '银行卡'
}
</script>
<template>
  <div class="xtx-pay-page" style="margin-top: 20px">
    <div class="container">
      <!-- 支付结果 -->
      <div class="pay-result">
        <template v-if="route.query.payResult === 'true'">
          <span class="iconfont icon-queren2 green"></span>
          <p class="tit">订单支付成功</p>
          <p class="tip">我们将尽快为您发货，收货期间请保持手机畅通</p>
          <p>
            支付方式：<span>{{ PAYTYPE[orderDetail.payType] }}</span>
          </p>
          <p>
            支付金额：<span>¥{{ orderDetail.payMoney?.toFixed(2) }}</span>
          </p>
        </template>
        <template v-else>
          <span class="iconfont icon-shanchu red"></span>
          <p class="tit">订单支付失败</p>
          <p class="tip">或许成为遗憾才能让人念念不忘</p>
        </template>
        <div class="btn">
          <XtxButton type="primary" style="margin-right: 20px" @click="$router.push('/')">查看订单</XtxButton>
          <XtxButton type="gray" @click="$router.push('/')">进入首页</XtxButton>
        </div>
        <p class="alert">
          <span class="iconfont icon-tip"></span>
          温馨提示：小兔鲜儿不会以订单异常、系统升级为由要求您点击任何网址链接进行退款操作，保护资产、谨慎操作。
        </p>
      </div>
    </div>
  </div>
</template>
<script>
export default {
  name: 'XtxPayResultPage'
}
</script>
<style scoped lang="less">
.pay-result {
  padding: 100px 0;
  background: #fff;
  text-align: center;
  > .iconfont {
    font-size: 100px;
  }
  .green {
    color: #1dc779;
  }
  .red {
    color: @priceColor;
  }
  .tit {
    font-size: 24px;
  }
  .tip {
    color: #999;
  }
  p {
    line-height: 40px;
    font-size: 16px;
  }
  .btn {
    margin-top: 50px;
  }
  .alert {
    font-size: 12px;
    color: #999;
    margin-top: 50px;
  }
}
</style>
